//
//  MeatBaseBox.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/25.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatBaseBox.h"

@implementation MeatBaseBox

#pragma mark - lifecycle methods

- (void)setupUI{
    
    self.backgroundColor = KClearColor;
    [self addSubview:self.contentView];
}


- (void)setupLayout{
    
    self.height = KScreenHeight;
    [self setupContentLayout];
}


- (void)setupContentLayout{
    
}


/**
 Show Box
 */
- (void)showView{
    
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    [window addSubview:self];
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)]];
    //遮罩
    kWeakSelf(self);
    [window addSubview:self.contentView];
    _contentView.transform = CGAffineTransformMakeTranslation(0.01, KScreenWidth);
    [UIView animateWithDuration:AnimationTime animations:^{
        weakself.contentView.transform = CGAffineTransformMakeTranslation(0.01, 0.01);
    }];
}


/**
 Hide Box
 */
- (void)dismissView {
    
    [self postMeatScreeningHideNotification];
    
    kWeakSelf(self);
    [UIView animateWithDuration:AnimationTime animations:^{
        weakself.contentView.transform = CGAffineTransformMakeTranslation(0.01, KScreenWidth);
        
        weakself.alpha = 0;
    } completion:^(BOOL finished) {
        [weakself removeFromSuperview];
        [weakself.contentView removeFromSuperview];
    }];
    
}

- (void)postMeatScreeningHideNotification{
    
}


- (UILabel *)createCommonLabel{
    
    UILabel *label = [UILabel makeLabelWithText:@"" textColor:mMainTextColor font:mFont(14) textAliment:0];
    label.size = CGSizeMake(100, 20);
    label.mj_x = 15;
    return label;
}

- (UIButton *)createCommonBtn{
    
    UIButton *btn = [UIButton makeButtonWithText:@"" textColor:mMainTextColor font:mFont(12) textAliment:1 cornerRadius:5];
    btn.size = CGSizeMake(74, 35);
    return btn;
}

- (void)setupBtnChoosedState:(UIButton *)btn{
    
    btn.backgroundColor = KWhiteColor;
    [btn setTitleColor:mMainColor forState:UIControlStateNormal];
    btn.layer.borderWidth = 1.0f;
    btn.layer.borderColor = mMainColor.CGColor;
}


#pragma mark - setter methods

#pragma mark - getter methods

- (UIView *)contentView{
    
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
    }
    return _contentView;
}


@end
